<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
  <th:block th:include="include :: header('商品自定义档案列表')"/>
</head>
<body class="gray-bg">
<section class="section-content">
  <div class="row">
    <div class="col-xs-12">
      <div class="ibox float-e-margins">
        <div class="ibox-content" style="border-style:none;">
          <div class="nav-tabs-custom">
            <ul class="nav nav-tabs">
              <li class="active"><a href="#tab-attribute" data-toggle="tab" aria-expanded="true">属性</a></li>
              <li><a href="#tab-field" data-toggle="tab" aria-expanded="false">字段</a></li>
              <li class="pull-right header">
                <i class="fa fa-code"></i> 自定义档案
              </li>
            </ul>
            <div class="tab-content">
              <!-- 属性 -->
              <div class="tab-pane" id="tab-attribute">
                <div class="btn-group-sm" id="toolbar" role="group">
                  <a class="btn btn-success" onclick="add()" shiro:hasPermission="product:customRecord:add">
                    <i class="fa fa-plus"></i> 添加
                  </a>
                  <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="product:customRecord:edit">
                    <i class="fa fa-edit"></i> 修改
                  </a>
                  <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()"
                     shiro:hasPermission="product:customRecord:remove">
                    <i class="fa fa-remove"></i> 删除
                  </a>
                  <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="product:customRecord:export">
                    <i class="fa fa-download"></i> 导出
                  </a>
                </div>
                <div class="col-sm-12 select-table table-striped">
                  <table id="bootstrap-table-attribute"></table>
                </div>
              </div>

              <!-- 字段 -->
              <div class="tab-pane active" id="tab-field">
                <div class="select-table table-striped" style="margin-top: 0px;padding-top: 0px;padding-bottom: 0px;">
                  <table id="bootstrap-table-field"></table>
                </div>
              </div>

            </div>
          </div>
        </div>
<!--        <div class="box-footer">-->
<!--          <div class="col-sm-offset-5 col-sm-6">-->
<!--            <button type="button" class="btn btn-sm btn-primary" onclick="submitHandler()"><i class="fa fa-check"></i>保 存</button>&nbsp;-->
<!--            <button type="button" class="btn btn-sm btn-danger" onclick="closeItem()"><i class="fa fa-reply-all"></i>关 闭</button>-->
<!--          </div>-->
<!--        </div>-->
      </div>
    </div>
  </div>
</section>
<th:block th:include="include :: footer"/>
<script th:inline="javascript">
  var editFlag = [[${@permission.hasPermi('product:customRecord:edit')}]];
  var removeFlag = [[${@permission.hasPermi('product:customRecord:remove')}]];
  var typeDatas = [[${@dict.getType('pro_custom_record_type')}]];
  var statusDatas = [[${@dict.getType('pro_custom_record_status')}]];
  var prefix = ctx + "product/customRecord";

  $(function () {
    var options = {
      id: "bootstrap-table-attribute",
      url: prefix + "/list",
      createUrl: prefix + "/add",
      removeUrl: prefix + "/remove",
      updateUrl: prefix + "/edit/{id}",
      modalName: "属性",
      columns: [{
        checkbox: true
      },
        {
          field: 'customRecordId',
          title: '商品自定义档案id',
          visible: false
        },
        {
          field: 'typeId',
          title: '商品类型id'
        },
        {
          field: 'name',
          title: '名称'
        },
        {
          field: 'type',
          title: '类型',
          formatter: function (value, row, index) {
            return $.table.selectDictLabel(typeDatas, value);
          }
        },
        {
          field: 'status',
          title: '状态',
          formatter: function (value, row, index) {
            return $.table.selectDictLabel(statusDatas, value);
          }
        },
        {
          field: 'remark',
          title: '备注'
        },
        {
          title: '操作',
          align: 'center',
          formatter: function (value, row, index) {
            var actions = [];
            actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\''
                + row.customRecordId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
            actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\''
                + row.customRecordId + '\')"><i class="fa fa-remove"></i>删除</a>');
            return actions.join('');
          }
        }]
    };
    $.table.init(options);
  });

  $(function () {
    var options = {
      id: "bootstrap-table-field",
      url: prefix + "/list",
      createUrl: prefix + "/add",
      removeUrl: prefix + "/remove",
      updateUrl: prefix + "/edit/{id}",
      modalName: "字段",
      columns: [{
        checkbox: true
      },
        {
          field: 'customRecordId',
          title: '商品自定义档案id',
          visible: false
        },
        {
          field: 'typeId',
          title: '商品类型id'
        },
        {
          field: 'name',
          title: '名称'
        },
        {
          field: 'type',
          title: '类型',
          formatter: function (value, row, index) {
            return $.table.selectDictLabel(typeDatas, value);
          }
        },
        {
          field: 'status',
          title: '状态',
          formatter: function (value, row, index) {
            return $.table.selectDictLabel(statusDatas, value);
          }
        },
        {
          field: 'remark',
          title: '备注'
        },
        {
          title: '操作',
          align: 'center',
          formatter: function (value, row, index) {
            var actions = [];
            actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\''
                + row.customRecordId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
            actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\''
                + row.customRecordId + '\')"><i class="fa fa-remove"></i>删除</a>');
            return actions.join('');
          }
        }]
    };
    $.table.init(options);
  });

  /*自定义档案-自定义档案*/
  function add() {
    var proTypeId = $("#proType option:selected").val();
    $.operate.add(proTypeId);
  }
</script>
</body>
</html>